<template>
  <div class="app">
    <div class="content">
      <div class="content-row">
        <div
          v-for="item in challengeModules"
          :key="item.id"
          :style="{ backgroundImage: 'url(' + item.fullFilePath + ')' }"
          class="content-col"
          @click="toSence(item.sceneType)"
        ></div>
      </div>
    </div>
    <div class="return" @click="back"></div>
  </div>
</template>

<script>
import { BizChallengeModuleController } from '@/api';
export default {
  name: 'frontChallenge',
  data() {
    return {
      moduleType: 2,
      personnelType: null,
      challengeModules: []
    };
  },
  methods: {
    toSence(sceneType) {
      if (!sceneType) {
        this.$message.warning('该模块暂未开放!');
      }
      this.$router.replace({
        name: 'frontScene',
        query: { sceneType: sceneType, personnelType: this.personnelType }
      });
    },
    back() {
      this.$router.replace({ name: 'course', query: { personnelType: this.personnelType } });
    },
    getModules() {
      BizChallengeModuleController.findByFront(this, {}).then(res => {
        console.log(res);
        this.challengeModules = res.data;
      });
    }
  },
  mounted() {
    const personnelType = this.$route.query.personnelType;
    this.personnelType = personnelType;
    this.getModules();
  }
};
</script>

<style type="scss" scoped>
.app {
  background-image: url('~@/assets/img/bg.png');
  background-size: cover;
  display: flex;
  justify-content: center; /* 水平居中 */
  align-items: center; /* 垂直居中 */
  height: 100vh; /* 让父容器充满整个视口高度 */
}
.content {
  width: 80%;
  height: 78%;

  .content-row {
    display: flex;
    flex-wrap: wrap;

    .content-col {
      flex: 1 1 22%;
      width: 325px;
      height: 400px;
      margin: 5px;
      box-sizing: border-box;
      cursor: pointer;
      flex-direction: column;
      justify-content: center; /* 垂直居中 */
      align-items: center; /* 水平居中 */
      font-size: 18px;
      text-align: center;
      vertical-align: middle;
      background-position: center center;
      background-repeat: no-repeat;
      background-size: contain;
    }
    .place {
      background-image: url('~@/assets/img/place.png');
    }
    .goods {
      background-image: url('~@/assets/img/huowu.png');
    }
    .archive {
      background-image: url('~@/assets/img/danzheng.png');
    }
    .safety {
      background-image: url('~@/assets/img/jizhuang.png');
    }
    .sys {
      background-image: url('~@/assets/img/sys.png');
    }
    .tool {
      background-image: url('~@/assets/img/sys.png');
    }
  }
}
.return {
  width: 252px;
  height: 66px;
  background-image: url('~@/assets/img/return.png');
  background-size: cover;
  position: absolute;
  bottom: 5%;
  cursor: pointer;
}
</style>
